package com.compass.doctor.dialog

import android.view.Gravity
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.fragment.app.FragmentActivity
import com.compass.doctor.callback.OnRefusalButtonClick
import com.compass.doctor.databinding.DialogRefusalBinding
import com.compass.framework.base.BaseDialog
import com.compass.framework.base.BaseDialogFragment
import com.compass.framework.ext.onClick
import com.compass.framework.toast.TipsToast

/**
 * Description： 拒诊Dialog
 * Date:2023/12/12 15:38
 */
class RefusalDialog {
    class Builder(activity: FragmentActivity, id: String, onRefusalBottomClick: OnRefusalButtonClick) : BaseDialogFragment.Builder<Builder>(activity) {

        private var orderId: String
        private var onButtonClick: OnRefusalButtonClick? = null
        private val mBinding: DialogRefusalBinding =
            DialogRefusalBinding.inflate(LayoutInflater.from(activity))

        init {
            onButtonClick=onRefusalBottomClick
            orderId = id
            initView()

        }

        private fun initView() {
            setContentView(mBinding.root)
            setWidth(ViewGroup.LayoutParams.MATCH_PARENT)
            setHeight(ViewGroup.LayoutParams.WRAP_CONTENT)
            setAnimStyle(BaseDialog.AnimStyle.BOTTOM)
            gravity = Gravity.BOTTOM
            mBinding.tvRefusal.onClick {
                var suggest=mBinding.edtSuggest.text.toString().trim()
                if (suggest.isNotEmpty()){
                    dismiss()
                    onButtonClick?.onButtonCallBack(orderId,suggest)

                }else{
                    TipsToast.showTips("请输入拒诊原因")
                }
            }

            mBinding.tvCancel.onClick {
                dismiss()
            }
        }

    }
}
